package DMSXL._2023Before.String_;

/*public class reverseStr_ {
    public static void main(String[] args) {
        String s = "abcd";
        System.out.println(s);
        Solution solution = new Solution();
        s = solution.reverseStr(s,4);

        System.out.println(s);
    }
}

class Solution {
    public String reverseStr(String s, int k) {
        char[] ch = s.toCharArray();
        if(s.length() <= k){
            replace(ch,0,s.length() - 1);
            return String.valueOf(ch);
        }
        int l = s.length()/k;

        for (int i = 1; i <= l ; i++) {
            if(i % 2 !=0){
                replace(ch,(i-1) * k,i*k -1);
            }
        }
        if(s.length() - l*k > 0 && l%2 == 0){
           replace(ch,l*k,s.length() - 1);
        }
        return String.valueOf(ch);
    }
    public void replace(char[] ch, int start ,int end) {

        int len = (end - start)+1;
        for (int i = 0; i < len/2; i++) {
            char temp = ch[start];
            ch[start] = ch[end];
            ch[end] = temp;
            start++;
            end--;
        }
    }
}*/